package com.lyc.mapper;

import com.lyc.pojo.ItemType;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ItemTypesMapper {
    // 查询所有分类
    @Select("SELECT * FROM item_types ORDER BY sort_order ASC")
    List<ItemType> getItemTypes();

    // 添加分类
    @Insert("INSERT INTO item_types(category_id, name, description, icon, sort_order, status) " +
            "VALUES(#{categoryId}, #{name}, #{description}, #{icon}, #{sortOrder}, #{status})")
    void addItemType(ItemType itemType);

    // 根据ID查询分类
    @Select("SELECT * FROM item_types WHERE id = #{id}")
    ItemType getItemTypeById(Integer id);

    // 更新分类
    @Update("UPDATE item_types SET category_id=#{categoryId}, name=#{name}, description=#{description}, icon=#{icon}, " +
            "sort_order=#{sortOrder}, status=#{status} WHERE id = #{id}")
    void updateItemType(ItemType itemType);

    // 删除分类
    @Delete("DELETE FROM item_types WHERE id = #{id}")
    void deleteItemType(Integer id);

    // 更新分类状态
    @Update("UPDATE item_types SET status=#{status} WHERE id = #{id}")
    void updateItemTypeStatus(@Param("id") Integer id, @Param("status") String status);
}